package com.sci.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sci.entity.Business;
import com.sci.mapper.BusinessMapper;
import com.sci.service.BusinessService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessServiceImpl implements BusinessService {
    @Resource
    private BusinessMapper businessMapper;


    @Override
    public List<Business> findAllBusiness() {
        List<Business> businesses = businessMapper.selectList(null);
        return businesses;
    }

    @Override
    public List<Business> getBusinessesByType(Integer type) {
        // 使用QueryWrapper构建查询条件
        QueryWrapper<Business> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type", type); // 字段名对应数据库列名
        return businessMapper.selectList(queryWrapper);
    }

    @Override
    public List<Business> searchBusiness(String keyword) {
        return businessMapper.search(keyword);
    }

    @Override
    public Business getBusinessById(String id) {
        QueryWrapper<Business> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("business_id", id);
        return businessMapper.selectOne(queryWrapper);
    }
}
